Currency Type
A structure that represents a single type of currency, identified by the three digit currency code. A stock or security in Moneydance is represented as a currency as it is a unit of value that is relative to some other value (ie the base currency)
Types
Properties
Returns the address book entry (if any) that is associated with this transaction.
Returns all ID schemes that have at least one identifier stored for this CurrencyType (e.g. "sedol", "isin", "cusip"). Covers both the MD2027+ multi-ID prefix ("curr_ids.") and the legacy single-ID prefix ("curr_id."), so pre-MD2027 data is found too.
Returns the date of the first/earliest snapshot, if any
If a syncable item is part of a grouped object, where multiple MoneydanceSyncableItems are part of the same syncable object, then this returns the parent object. An example is for SplitTxn which is not synced itself, but its associated ParentTxn is, so the SplitTxn class should override this method to return getParentTxn(). The default implementation here returns 'this'.
Returns the date of the last/latest snapshot, if any
The number of decimal places to show when displaying prices of this security/currency. This is generally only used for securities, and only in UI - it is not used when formatting prices for storage
Return whether this item should be shown in the sidebar, which prefers a local file setting, followed by an object parameter, falling back to using defaultSidebarVisibility which returns true if the item would be expected to appear in the sidebar by default, such as in the case of bank, credit card, or investment accounts, or memorised reports and graphs.
Subclasses should override this to return a static string identifying their type of object
Functions
Adds the given ID to the list of IDs that can refer to this currency or security using the given scheme
Add/merge all parameters from the given map that don't already have a key in the internal map
Create a new snapshot with the given date and (base currency) rate and return the result after adding it to the snapshot list.
Create a new snapshot with the given date and rate and return the result after adding it to the snapshot list.
Add a stock split.
Add a stock split with the given ratio (which should match the old/new shares) on the given date (which decimal form is YYYYMMDD)
Set the TagSet associated with this object. This should only be called when initially constructing this object from old data files. In other words, DON'T USE THIS!
Given a value for this currency at the specified day, return the equivalent value in the currency today after adjusting for splits.
Given a rate for this currency at the specified day, return the equivalent rate in the currency at endDate after adjusting for splits.
Convert a number of shares of this security to account for stock splits between two dates. If you have 100 units of this currency (value) on fromDate (20230101) and there is a single 2:1 stock split on 20230115, and toDate is 20230131, then this will return 200. This works in both directions, regardless or whether fromDate comes after or before toDate.
Given a number of currency units on the given day, return the equivalent number of units in today's currency value. This is intended to be used mainly for stock splits.
Given a number of currency units on the given day, return the equivalent number of units in today's currency value. This is intended to be used mainly for stock splits. Note: the result is deliberately rounded after each split calculation as in real life the new post-split share qty would crystallize into real shares and this value needs to be constant. If you allowed a calculation to maintain decimal precision over several split calculations, then you could end up with a different final share quantity.
Given a number of currency units on the given day, return the equivalent number of units in the endDate's currency value. This is intended to be used mainly for stock splits. Note: the result is deliberately rounded after each split calculation as in real life the new post-split share qty would crystallize into real shares and this value needs to be constant. If you allowed a calculation to maintain decimal precision over several split calculations, then you could end up with a different final share quantity.
Return true if any changes to this object are automatically synced
Return an integer indicating whether this currency is less than, equal to, or greater than the given currency when sorting by type, name, and ID. This method was added in build 600 (Moneydance 2008)
Updates the exchange rate of this currency to reflect the new base rate of newBaseType.
Convert the given baseCurrencyAmount value to it's value in this currency.
Deletes this item and all the snapshots and splits that reference it. Use with caution!
Return a clone of this object with the same backing info
Format the given value with the format
Format the given value with the format NNNN
Formats the given value (rate/price) into a string, rounding according to this currency/security's priceDisplayDecimalPlaces setting. When both priceDisplayDecimalPlaces and defaultMaxDecPlaces (defaults) are null then no rounding will take place.
Format the given value with the format N,NNN.NN
Lookup and return an account that was referenced by this object using one of the given parameter names. Priority is given to acctIDKey which should reference the UUID of the account being referenced. If the acctIDKey lookup is not successfull then a lookup is done using the acctNumKey which references the integer account ID that is returned by getAccountNum() on the referenced account. If either acctNumKey or acctIDKey is null then that key is not checked for an account reference.
Lookup and return an address book entry that was referenced by this object using one of the given parameter names. Priority is given to addressIDKey which should reference the UUID of the address being referenced. If the addressIDKey lookup is not successfull then a lookup is done using the addressNumKey which references the integer address ID that is returned by getID() on the referenced account. If either addressNumKey or addressIDKey is null then that key is not checked for an account reference.
Get the specified parameter as a boolean. If the given parameter does not have a value, or if it is not a boolean, return null
Get the specified parameter as a boolean. If the given parameter does not have a value, or if it is not a boolean, return the given default value
Lookup and return the currency referenced by this object using the given parameter key
Lookup and return a currency that was referenced by this object using one of the given parameter names. Priority is given to currIDKey which should reference the UUID of the currency being referenced. If the currIDKey lookup is not successfull then a lookup is done using the currNumKey which references the integer account ID that is returned by getID() method on the referenced currency. If either currNumKey or currIDKey is null then that key is not checked for a currency reference.
Lookup and return a currency that was referenced by this object using one of the given parameter names. Priority is given to currIDKey which should reference the UUID of the currency being referenced. If the currIDKey lookup is not successfull then a lookup is done using the currNumKey which references the integer account ID that is returned by getID() method on the referenced currency. If no currency has been found then the parameter value associated with the currencyIDString key is checked for a currency ID string (usually the three character ISO currency ID). Any of the parameters currNumKey, currIDKey, or currencyIDString can be null in which case that parameter is not checked for a currency reference.
Get the specified parameter as a double (64 bit) float. If the given parameter does not have a value, or if it is not an double, return the given defaul value
Get the 64 bit floating point representation of the given integer amount of this currency
Returns the security/currency ID that was set for this CurrencyType using the given ID scheme. Returns null if no ID was set using the given scheme.
Returns the list of strings that was stored with setInlineStringListParameter, or null if the parameter has no value.
Get the specified parameter as an integer. If the given parameter does not have a value, or if it is not an integer, return the given defaul value
Get the specified parameter as a long. If the given parameter does not have a value, or if it is not a long, return null
Get the specified parameter as a long. If the given parameter does not have a value, or if it is not a long, return the given default value. This method was created as of build 254.
If this is an editing copy of an item, return the original
Get the specified parameter name. If the given parameter does not have a value, return the given defaultStr
Returns the String value associated with the given key in the local data file-specific preferences
Returns the boolean value associated with the given key in the local data file-specific preferences. If it's not found in the local datastore then check this object's syncable parameters for the same key
Returns the boolean value associated with the given key in the local data file-specific preferences
Returns the double value associated with the given key in the local data file-specific preferences
Returns the integer value associated with the given key in the local data file-specific preferences
Returns an array of integers from in the local data file-specific preferences that were stored using setPreference(String, int[])
Returns the long value associated with the given key in the local data file-specific preferences
Return a list of string values that were stored with setPreference(key, ...) (ie in the local data file-specific preferences)
Returns a list of SyncRecord objects which were stored with setPreference(key, ...) in the local data file-specific preferences.
Returns a new SyncRecord with the key-value pairs for which the keys have the given prefix in the local data file-specific preferences.
Get the rate of this currency relative to the given currency. If relativeToCurrency is null then the rate is returned in terms of the base currency.
Get the rate of this currency relative to the given currency as of the given date. If relativeToCurrency is null then the rate is returned in terms of the base currency.
Return the user rate as of the given date. Deprecated: please use getRate(date, relativeCurrency)
Get the last known raw rate for this currency at the given time. Deprecated: please use getSnapshotForDate(date) and getRawRate()
Returns the currency to which this item's rates are relative. Note: Only securities are permitted to have a relative currency that is not the base currency.
Get the rate in terms of the relative currency as of the given date. If there is no relative currency then this returns the rate in terms of the base currency.
This finds the best historical price entry (aka snapshot) to use for the value of this currency or security on the given date. The best entry should be the latest entry on or before the given date. If that doesn't exist, then the earliest entry after that date. If that doesn't exist then this returns null, in which case the caller should use the current rate or price rather than a snapshot.
Return the split ratio for shares of this security between the two dates. You can multiply the result by the number of shares on fromDate to get the equivalent number of shares on toDate. This works in both directions, so the calculation will be valid even if fromDate is later than toDate.
Return a list of string values that were stored with setPreference(key, ...) (ie in the local data file-specific preferences)
Returns a list of SyncRecord objects which were stored with setParameter(key, sublist)
Returns a SyncRecord map which was stored with setParameter(key, Map)
Get the rate relative to the base currency
Return the user rate as of the given date. Deprecated: please use getSnapshotForDate(date) and getRate(relativeCurrency)
Returns true if this object has already been recorded as part of this data set. This can often be used to tell whether we're creating a new object or editing an existing one, for example in a transaction or account editor form.
Convert the given currencyAmount value in this currency to a value in the base currency.
This is called after an item is updated by calling itemWasUpdated(SyncRecord). This can occur from the syncing process or from being loaded locally. Override this method to be notified.
This is called just before an item will be stored and/or synced when itemWillSync(SyncRecord) is called. Override this method to be notified or if you'd like to store anything into the info record to be synced.
Parse the given amount string given the provided decimal character. If quickDecimal is true and getDecimalPlaces() is 2 then a decimal point will be inserted into the string so that "1234" will be parsed as if the user entered "12.34"
Remove the parameter with the given name.
Store a reference to acct in this object using the given keys. The acctNumKey, if non-null, refers to the number returned by acct.getAccountNum(). The acctIDKey, if non-null, refers to the string returned by acct.getUUID() and will generally be more reliable and have a faster lookup time. If not storing references to accounts that have been migrated from before Moneydance 2015 then please only use the acctIDKey to store references.
Store a reference to address in this account using the keys. The acctNumKey, if non-null, refers to the number returned by address.getAccountNum(). The acctIDKey, if non-null, refers to the string returned by address.getUUID() and will generally be more reliable and have a faster lookup time. If not storing references to accounts that have been migrated from before Moneydance 2015 then please only use the acctIDKey to store references.
Store a reference to the given currency in this object using the given parameter key.
Store a reference to currency in this object using the given keys. The currNumKey, if non-null, refers to the number returned by curr.getID(). The currIDKey, if non-null, refers to the string returned by curr.getUUID() and will generally be more reliable and have a faster lookup time. If not storing references to accounts that have been migrated from before Moneydance 2015 then please only use the acctIDKey to store references.
Put the object into "editing mode" in which no changes will be automatically saved until you call syncItem() on this. Note that calling duplicate() will put the new duplicate into editing mode automatically
Sets the security/currency ID for the given ID scheme. If the given ID is null, then removes all identifiers with the given scheme. NOTE: the behavior has changed as of MD2027, in that there can now be more than one ID for each scheme. Setting an ID for a scheme with this method will now overwrite or remove (if newID is null) all IDs associated with the given scheme.
Store the given list of strings in a single parameter, instead of the parameter-per-item that setParameter(name, List) stores. Read it back with getInlineStringListParameter.
Set the given parameter name to the given boolean value
Set the given parameter name to the given double value
Set the given parameter name to the given integer value
Set the given parameter name to the given long value
Set the given parameter name to the given value but don't notify listeners of changes!
Set the given parameter name to the given boolean value, without sending an account-changed event, or recording the account as dirty.
Set the given parameter name to the given integer value, without sending an account-changed event, or recording the account as dirty.
Set the given preference name to the given value and associate it with this object in local storage. This will not be synced and neither will it result in any modification notifications being triggered.
Saves the given sublist into local storage, associated with this object. Values can be retrieved using getPreferenceSublist(prefix).
Set the new user (not raw) rate to the given value relative to the given currency. If relativeCurr is null then the given rate is considered to be relative to the base currency.
Set the rate relative to the base currency already adjusted for differences in decimal places between this currency and the base currency.
Sets the currency to which this item's rates are relative. Note: Only securities are permitted to have a relative currency that is not equal to the base currency.
If a snapshot exists for the specified date, set the rate and return it. Otherwise create a new snapshot on that date with the given rate and return the new snapshot.
If a snapshot exists for the specified date, set the rate and return it. Otherwise create a new snapshot on that date with the given rate and return the new snapshot. If relativeCurr is non-null then the price is first converted to the base price by getting the price of the given currency on the given date.
Set the price or rate for this currency using the normal decimal placement, not the decimal place adjusted values used when setting raw rates. Note: if there is a relative currency for this currency, then the given rate is assumed to be relative to that currency.
Set the new user (not raw) rate to the given value relative to the given currency.
Returns the earliest snapshot that is on or after the given date, or null if there are no snapshots on or after the given date.
Returns the latest snapshot on or before the given date, or null if there are no snapshots on or after the given date.
Given a number of currency units as of today, return the equivalent number of units in the asofDate's currency value, which must be a previous date. This is intended to be used mainly for stock splits. Note: the result is deliberately rounded after each split calculation as in real life the new post-split share qty would crystallize into real shares and this value needs to be constant. If you allowed a calculation to maintain decimal precision over several split calculations, then you could end up with a different final share quantity.